package com.tanhua.dubbo.db.api;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tanhua.dubbo.db.mappers.SettingsMapper;
import com.tanhua.model.db.Settings;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

@DubboService
public class SettingsApiImpl implements SettingsApi {

    @Autowired
    private SettingsMapper settingsMapper;

    //根据userId查询
    @Override
    public Settings findByUserId(Long userId) {


        QueryWrapper<Settings> qw=new QueryWrapper<>();
        qw.eq("user_id",userId);

        Settings settings = settingsMapper.selectOne(qw);
        return settings;
    }

    //保存
    @Override
    public void saveSettings(Settings settings) {
        settingsMapper.insert(settings);
    }

    //更新
    @Override
    public void updateSettings(Settings settings) {
        settingsMapper.updateById(settings);
    }
}
